<%@page import="com.blockchain.front.servlets.SendEmailCode"%>
<%@page import="com.blockchain.front.servlets.password.ResetExists"%>
<%@page import="com.blockchain.front.servlets.password.ResetVerify"%>
<%@page import="com.blockchain.front.servlets.password.Iphone"%>
<%@page import="com.blockchain.front.servlets.TxYzmExists"%>
<%@page import="com.blockchain.front.servlets.RegisterVerify"%>
<%@page import="com.blockchain.front.servlets.password.Reset"%>
<%if(blockchainSession!=null&&blockchainSession.isAuthenticated()){ controller.forwardController(request, response, Index.class);return;} %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.blockchain.common.enums.TermType"%>
<%@page import="com.blockchain.front.servlets.Term"%>
<%@page import="com.blockchain.front.servlets.Send"%>
<%@page import="com.blockchain.front.servlets.CheckNameExists"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<html>
<head>
<%
String str = languageDefine.getValue(request, "reset_getPasswordBack");
String _TITLE_ = str + " - "+configureProvider.getProperty(SystemVariable.SITE_NAME);
String _KEYWORDS_ = "NEW币网，井通币，井通SWT，SWT，虚拟币，虚拟货币，数字资产，数字货币，数字货币交易平台，比特币，比特币价格，比特币交易，以太坊，以太坊价格，以太坊走势，狗狗币，莱特币，点点币";
String _DESCRIPTION_ = "NEW币网，综合数字货币交易平台，拥有专业的团队、先进的技术和资深的行业经验，致力于成为中国最稳定、最安全、最专业、最全面的数字货币、数字资产、虚拟货币综合交易平台。";
%>
<title><%=_TITLE_ %></title>
<%@include file="/WEB-INF/include/meta.jsp"%>
<meta name="keywords" content="<%=_KEYWORDS_ %>">
<meta name="description" content="<%=_DESCRIPTION_ %>">
<%@include file="/WEB-INF/include/style.jsp"%>
</head>
<body >
<body>
<%@include file="/WEB-INF/include/header.jsp"%>
<div class="wrapper">
 <%String errorMessage = controller.getPrompt(request,response,PromptLevel.ERROR);%>
    <form action="<%=controller.getURI(request, Reset.class)%>" method="post" onsubmit="return onSubmit()">
    <div class="register" style="border-radius: 15px; margin-bottom: 20px;">
    <div class="com_warning"  style="padding-left: 492px;margin-top:40px;line-height: 54px;"><%StringHelper.filterHTML(out, null==errorMessage?"":(errorMessage.indexOf("err_")!=-1?languageDefine.getValue(request, errorMessage):errorMessage));%></div>
        <table style="margin-top:0;">
        
            <tbody>
                <tr>
                    <th align="right"><%=languageDefine.getValue(request, "reset_phoneNumber")%>：</th>
                    <td><div class="formbody" style="width: 250px;">
                            <i class="icon_phone"></i>
                            <input type="text" class="username" id="moble" name="phone"  onblur="phoneCheck();" placeholder='<%=languageDefine.getValue(request, "reset_pleaseEnterPhone")%>' value="<%StringHelper.filterHTML(out,request.getParameter("phone"));%>">
                        </div></td>
                </tr>
                <tr>
                    <th align="right"><%=languageDefine.getValue(request, "reset_captcha")%>：</th>
                    <td><div class="formbody">
                            <i class="icon_code"></i>
                            <input maxlength="4" type="text" class="code" id="verify" onblur="txverifyCheck();"  name="txverifyCode"   placeholder='<%=languageDefine.getValue(request, "reset_pleaseEnterVerificationCode")%>' style="width: 100px;">
                            <img id="codeImg" src="<%=controller.getURI(request, ResetVerify.class)%>" width="145" height="42" onclick="this.src='<%=controller.getURI(request, ResetVerify.class)%>?'+Math.random()" style="float: left; cursor: pointer;" title='<%=languageDefine.getValue(request, "reset_change")%>'>
                        </div></td>
                </tr>
                <tr>
                    <th align="right"><%=languageDefine.getValue(request, "reset_smsVerificationCode")%>：</th>
                    <td><div class="formbody">
                            <i class="icon_code"></i>
                            <input maxlength="4" type="text" class="code" id="moble_verify" name="dxverifyCode" onblur="dxverifyCheck();"  placeholder='<%=languageDefine.getValue(request, "reset_pleaseEnterVerificationCode")%>' style="width: 100px;">
                            <input id="regBtn" type="button" class="getyzm" value='<%=languageDefine.getValue(request, "reset_getVerificationCode")%>' onclick="sendCode(this);" style="width: 142px;float:right; height: 42px;">
                        </div>
                        </td>
                </tr>
                <tr>
                    <th align="right"><%=languageDefine.getValue(request, "reset_newLoginPassword")%>：</th>
                    <td><div class="formbody" style="width: 250px;">
                            <i class="icon_password"></i>
                            <input type="password" class="password" id="password" name="password"  onblur="passwordCheck()" placeholder='<%=languageDefine.getValue(request, "reset_passwordReg")%>' value="<%StringHelper.filterHTML(out,request.getParameter("password"));%>">
                        </div></td>
                </tr>
                <tr>
                    <th align="right"><%=languageDefine.getValue(request, "reset_confrimLoginPassword")%>：</th>
                    <td><div class="formbody" style="width: 250px;">
                            <i class="icon_password"></i>
                            <input type="password" class="password" id="repassword" name="newPassword" onblur="rePasswordCheck()" placeholder='<%=languageDefine.getValue(request, "reset_EnterPasswordAgain")%>' value="<%StringHelper.filterHTML(out,request.getParameter("newPassword"));%>">
                        </div></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><div class="formbody">
                            <input type="submit" class="pocoins_btn" name="index_submit" id="Submin"  value='<%=languageDefine.getValue(request, "reset_getLoginPasswordBack")%>' title='<%=languageDefine.getValue(request, "reset_getLoginPasswordBack")%>' style="width: 320px;">
                        </div></td>
                    <td>&nbsp;</td>
                </tr>
            </tbody>
        </table>
    </div>
    </form>
</div>
<%@include file="/WEB-INF/include/footer.jsp"%>
<%@include file="/WEB-INF/include/script.jsp"%>
<script type="text/javascript">
var _tx_url='<%=controller.getURI(request,ResetExists.class)%>';
var _cUrl = '<%=controller.getURI(request, SendEmailCode.class)%>';
var phoneVal = /^(13|15|18|17|14|16|19)[0-9]{9}$/;
var isNull = /^[\s]{0,}$/;
var verify = /^\d{4}$/;
var phoneVal = /^(13|15|18|17|14|16|19)[0-9]{9}$/;
var emailVal = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/;
var verify = /^\d{4}$/;
var isNull = /^[\s]{0,}$/;
var wait = 60;
var codeVal=/^[A-Za-z0-9]{0,20}$/;
function phoneCheck() {
	var ipt = $("input[name='phone']");
	var val = ipt.val();
	var p =$("#moble-msg"); 
	 if(val==""||val==null){
         layer.tips(_error_global.js_enterEmailNum, '#moble', {tips: 3});
         return false;
     }
		if (!emailVal.test(val)) {
			layer.tips(_error_global.js_emailNumError, '#moble', {tips: 3});
			return false;
		}
		var data={"txverifyCode":ipt.val()};
		$.ajax({
			type:"post",
			dataType:"html",
			url:_cURL,
			data:data,
			success:function(data){
				if (data.trim() == 'true') {
					 layer.tips(_error_global.js_phoneNumExist, '#moble', {tips:3});
					return false;
				}}});
		return true;
}

function txverifyCheck() {
	var val = $("input[name='txverifyCode']").val();
	var p = $("#verify");
	if (isNull.test(val)) {
		layer.tips(_error_global.js_captchaNotNull, '#verify', {tips:3});
		return false;
	} else if (!verify.test(val)) {
		layer.tips(_error_global.js_captchaError, '#verify', {tips:3});
		return false;
	}
	return true;
}

function dxverifyCheck() {
	var val = $("input[name='dxverifyCode']").val();
	var p = $("#verify");
	if (isNull.test(val)) {
		layer.tips(_error_global.js_smsVerificationCodeNotNull, '#moble_verify', {tips:3});
		return false;
	} else if (!verify.test(val)) {
		layer.tips(_error_global.js_smsVerificationCodeError, '#moble_verify', {tips:3});
		return false;
	}
	return true;
}

function sendCode(evn){
	var ipt = $("input[name='phone']");
	var tx = $("input[name='txverifyCode']").val();
	var val = ipt.val();
	var p =$("#moble-msg"); 
	 if(val==""||val==null){
//       layer.tips(_error_global.js_enterPhoneNum, '#moble', {tips: 3});
       layer.tips(_error_global.js_enterEmailNum, '#moble', {tips: 3});
       return false;
   }
//	if (!phoneVal.test(val)) {
//		 layer.tips(_error_global.js_phoneNumError, '#moble', {tips: 3});
//		return false;
//	}
		if (!emailVal.test(val)) {
			layer.tips(_error_global.js_emailNumError, '#moble', {tips: 3});
			return false;
		}
	if (isNull.test(tx)) {
		layer.tips(_error_global.js_captchaNotNull, '#verify', {tips:3});
		return false;
	} else if (!verify.test(tx)) {
		layer.tips(_error_global.js_captchaError, '#verify', {tips:3});
		return false;
	}
	sendclick(evn);
	var datatx={"txverifyCode":tx};
	$.ajax({
		type:"post",
		dataType:"html",
		url:_tx_url,
		data:datatx,
		success:function(data){
			if(data==1){
				var data={"type":"RESET","phone":val};
				$.ajax({
					type:"post",
					dataType:"html",
					url:_cUrl,
					data:data,
					success:function(data){
						var ct = eval('('+data+')');
						if(ct.length>0){
							if(ct[0].num == 2){
							}
							layer.tips(ct[0].msg.indexOf("err_")!=-1?eval("_error_global."+ct[0].msg):ct[0].msg, '#regBtn', {tips: 2});
							return false;
						}
					}
				});
			}else{	
				layer.tips(data, '#verify', {tips: 2});
				return false;
			}
			}
	});
}
var wait = 60;
 function sendclick(evn){
	 var obj = $('#regBtn');
	 if (wait == 0) {
			obj.val(_error_global.js_getCaptcha);
            obj.css('backgroundColor', '#0d66bf');
			wait = 60;
		} else {
			 obj.css('backgroundColor', '#999B9C');
             obj.val(wait + _error_global.js_sendAgain);
             wait--;
			setTimeout(function() {
				sendclick(evn);
			},
			1000);
		}
	}
 
 function passwordCheck() {
		var ipt = $("input[name='password']");
		var val = ipt.val();
		if (isNull.test(val)) {
			layer.tips(_error_global.js_passwordCannotNull, '#password', {tips:3});
			return false;
		} else if (val.length<6 || val.length >16) {
			layer.tips(_error_global.js_passwordReg, '#password', {tips:3});
			return false;
		}
		return true;
	}
 
 function rePasswordCheck() {
		var ipt = $("input[name='password']");
		var _ipt = $("input[name='newPassword']");
		var val = ipt.val();
		var _val = _ipt.val();
		if (isNull.test(ipt.val())) {
			layer.tips(_error_global.js_enterPwd, '#repassword', {tips:3});
			return false;
		} else if (isNull.test(_val)) {
			layer.tips(_error_global.js_repeatNotPwd, '#repassword', {tips:3});
			return false;
		} else if (_val != val) {
			layer.tips(_error_global.js_passwordNotSame, '#repassword', {tips:3});
			return false;
		}
		return true;
	}
 
 function onSubmit()
 {
	
 	if (phoneCheck()&&txverifyCheck()&&dxverifyCheck()&&passwordCheck()&&rePasswordCheck()){
 		return true;
 	} 
 	return false;
 } 
</script>
</body>
</html>	
	
